package com.mp.approvalreq.entity.po;

import com.alibaba.fastjson.JSONObject;
import com.mp.approvalreq.entity.vo.Component;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author liuqi
 * @date 2018/9/18
 */
public class ComponentGroup implements Serializable {

    private Integer id;

    private Integer companyId;

    private String name;

    private Integer size;

    private Integer num;

    private Integer isCommonGroup;

    private Integer isAddComponentGroup;

    private List<Component> components;

    public ComponentGroup() {
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Integer getIsAddComponentGroup() {
        return isAddComponentGroup;
    }

    public void setIsAddComponentGroup(Integer isAddComponentGroup) {
        this.isAddComponentGroup = isAddComponentGroup;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public List<Component> getComponents() {
        return components;
    }

    public void setComponents(List<Component> components) {
        this.components = components;
    }

    public void setComponents(String components) {
		try {
			if (StringUtils.isNotEmpty(components)) {
				this.setComponents(JSONObject.parseArray(components, Component.class));
			}
		} catch (Exception e) {
			this.setComponents(new ArrayList<>());
		}
	}

    public Integer getIsCommonGroup() {
        return isCommonGroup;
    }

    public void setIsCommonGroup(Integer isCommonGroup) {
        this.isCommonGroup = isCommonGroup;
    }

    @Override
    public String toString() {
        return "ComponentGroup{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", 组件位置num=" + num +
                ", 子组件=" + components +
                '}';
    }


}
	